package com.yunxi.controller.base;

import com.alibaba.dubbo.config.annotation.Reference;
import com.yunxi.base.pojo.BaseApplyLevelVO;
import com.yunxi.base.service.BaseApplyLevelDubboService;
import com.yunxi.core.web.ApiResult;
import com.yunxi.core.web.CurrentUser;
import com.yunxi.core.web.LoginInfo;
import com.yunxi.core.web.ResponseUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author caoYong
 * @since 2019-07-23
 */
@RestController
@RequestMapping("/admin/baseapplylevel")
@Api(tags = "pms:baseapplylevel", description = "审核人维护接口")
public class BaseApplyLevelController {
 private static final Logger logger = LoggerFactory.getLogger(BaseApplyLevelController.class);

 @Autowired
 BaseApplyLevelDubboService baseApplyLevelDubboService;

 @GetMapping("/page")
 @ApiOperation(value = "查询分页")
 public ApiResult page(BaseApplyLevelVO baseApplyLevelVO, Integer pageNum, Integer pageSize) throws Exception {
  return ResponseUtil.ok(baseApplyLevelDubboService.findPageByVO(baseApplyLevelVO,pageNum,pageSize));
 }

@GetMapping("/list")
@ApiOperation(value = "查询列表")
public ApiResult list(BaseApplyLevelVO baseApplyLevelVO) throws Exception {
    return ResponseUtil.ok(baseApplyLevelDubboService.listByVo(baseApplyLevelVO));
}

 @GetMapping("/load")
 @ApiOperation(value = "读取单个")
 public ApiResult load(BaseApplyLevelVO baseApplyLevelVO, @CurrentUser LoginInfo loginInfo) throws Exception {
    return ResponseUtil.ok(baseApplyLevelDubboService.getById(baseApplyLevelVO.getLevelId()));
}

 @PostMapping("/save")
 @ApiOperation(value = "保存信息")
 public ApiResult save(@RequestBody BaseApplyLevelVO baseApplyLevelVO,@CurrentUser LoginInfo loginInfo) throws Exception {
    baseApplyLevelDubboService.saveOrUpdate(baseApplyLevelVO);
    return ResponseUtil.ok("success");
}

 @PostMapping("/del")
 @ApiOperation(value = "删除")
 public ApiResult del(@RequestBody List<BaseApplyLevelVO> baseApplyLevelVOList) throws Exception {
    baseApplyLevelDubboService.removeByListVo(baseApplyLevelVOList);
    return ResponseUtil.ok("success");
 }

/*@PostMapping("/export")
@ApiOperation(value = "导出excel")
public Object export(@RequestParam Map<String,Object> params) throws Exception {
return ResponseUtil.ok(baseApplyLevelDubboService.findMapByList(params));
}*/
}
